{include file="public/header" /}
<form class="layui-form">
	<input type="hidden" name="smid" value="{$lists.smid}">
	<div class="layui-form-item">
		<label class="layui-form-label">按钮名</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="label" placeholder="请输入按钮名" value="{$lists.label}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">图标</label>
		<div class="layui-input-block">
			<select name="icon_class" lay-verify="required" lay-search="">
				<option value="">请输入layui图标</option>
				{foreach($iconfont as $icon_v)}
					<option value="{$icon_v['icon_css']}" {if($icon_v['icon_css'] == $lists['icon_class'])}selected{/if}>{$icon_v['icon_css']} {$icon_v['icon_name']}</option>
				{/foreach}
			</select>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">类型</label>
		<div class="layui-input-inline">
			<select name="type" lay-filter="type">
				<option value='1' {$lists.type==1?'selected':''}>内部代码</option>
				<option value='2' {$lists.type==2?'selected':''}>超链接</option>
			</select>
		</div>
	</div>
	<div class="layui-form-item" {$lists.type==1?'style="display:none;"':''} id="src1">
		<label class="layui-form-label">内部代码</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="src1" placeholder="请输入：/项目/模块/方法" {if $lists.type==1}value="{$lists['src']}"{/if}>
		</div>
	</div>
	<div class="layui-form-item" {$lists.type==2?'style="display:none;"':''} id="src2">
		<label class="layui-form-label">链接地址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input" name="src2" placeholder="请输入http网址" {if $lists.type==2}value="{$lists['src']}"{/if}>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">排序</label>
		<div class="layui-input-block">
			<input type="number" class="layui-input" name="sort" placeholder="值越大越靠前" value="{$lists.sort}">
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">备注</label>
		<div class="layui-input-block">
			<textarea class="layui-textarea" name="remark" placeholder="请输入备注">{$lists['remark']}</textarea>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">状态</label>
		<div class="layui-input-block">
			<input type="radio" name="status" value="1" title="开启" {$lists['status']==1?'checked':''}>
			<input type="radio" name="status" value="0" title="禁用" {$lists['status']==0?'checked':''}>
		</div>
	</div>
	<div class="layui-form-item">
		<label class="layui-form-label">左侧菜单</label>
		<div class="layui-input-block">
			<input type="radio" name="is_show" value="1" title="显示" {$lists['is_show']==1?'checked':''}>
			<input type="radio" name="is_show" value="0" title="不显示" {$lists['is_show']==0?'checked':''}>
		</div>
	</div>
</form>
<div class="layui-form-item" style="margin-top:10px;">
	<div class="layui-input-block">
		<button type="button" class="layui-btn" onclick="save()">保存</button>
	</div>
</div>
<script type="text/javascript">
	layui.use(['layer','form'],function(){
		form = layui.form;
		layer = layui.layer;
		$ = layui.jquery;
		
		type({$lists.type});
		form.on('select(type)', function(data){
			type(data.value);
		});
	});
	function type(value){
		if(value == 1){
			$("#src1").show();
			$("#src2").hide();
			$("#src3").hide();
		}else if(value == 2){
			$("#src1").hide();
			$("#src2").show();
			$("#src3").hide();
		}else{
			$("#src1").show();
			$("#src2").hide();
			$("#src3").hide();
		}
	}
	function save(){
		$.post('{$config["admin_route"]}bew/buttonedit',$('form').serialize(),function(res){
			if(res.code>0){
				layer.msg(res.msg,{'icon':2});
			}else{
				layer.msg(res.msg,{'icon':1});
				setTimeout(function(){parent.window.location.reload();},1000);
			}
		},'json');
	}
</script>
{include file="public/tail" /}